<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    form {
      width: 650px;
      height: 40px;
      border: 1px solid skyblue;
      display: flex;
      justify-content: space-between;
      position: relative;
      margin: 50px auto;
    }

    form > button {
      width: 100px;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 20px;
      color: #fff;
      background-color: skyblue;
      outline: none;
      border: none;
    }

    form > input {
      flex: 1;
      padding-left: 20px;
      font-size: 20px;
      outline: none;
      border: none;
    }

    form > ul {
      position: absolute;
      width: 100%;
      border: 1px solid #333;
      top: 100%;
      border-top: none;
      left: -1px;
      display: none;
    }

    form > ul > li {
      list-style: none;
      height: 30px;
      font-size: 20px;
      padding-left: 20px;
      display: flex;
      align-items: center;
    }

    form > ul > li:hover {
      cursor: pointer;
      background-color: #ccc;
      color: #fff;
    }
  </style>
</head>
<body>
  <h1>模拟百度搜索引擎</h1>

  <form>
    <input type="text">
    <button>某度一下</button>
    <ul>
      <li>1</li>
      <li>2</li>
      <li>3</li>
      <li>4</li>
      <li>5</li>
      <li>6</li>
      <li>7</li>
      <li>8</li>
      <li>9</li>
      <li>10</li>
    </ul>
  </form>



  <!-- 

https://www.baidu.com/s?wd=你的关键词&rsv_spt=1&rsv_iqid=0xa66e02bc0004a89e&issp=1&f=8&rsv_bp=1&rsv_idx=2&ie=utf-8&tn=baiduhome_pg&rsv_dl=tb&rsv_enter=1&rsv_sug3=4&rsv_sug1=3&rsv_sug7=100&rsv_sug2=0&rsv_btype=i&prefixsug=emo&rsp=5&inputT=4949&rsv_sug4=8482
https://www.baidu.com/s?wd=你的关键词&rsv_spt=1&rsv_iqid=0xa66e02bc0004a89e&issp=1&f=8&rsv_bp=1&rsv_idx=2&ie=utf-8&rqlang=cn&tn=baiduhome_pg&rsv_dl=tb&rsv_enter=1&oq=emo&rsv_btype=t&inputT=4113&rsv_t=aca6di6H0FOI%2BM2EaWipiUUq9lvdvfZHCKnEJnNVUK4aArsHu%2Bhg8XGcaiqWKGvNcVEZ&rsv_pq=9af14d2600096938&rsv_sug3=14&rsv_sug1=13&rsv_sug7=100&rsv_sug2=0&rsv_sug4=4113
https://www.baidu.com/s?wd=你的关键词&rsv_spt=1&rsv_iqid=0xa66e02bc0004a89e&issp=1&f=8&rsv_bp=1&rsv_idx=2&ie=utf-8&rqlang=cn&tn=baiduhome_pg&rsv_dl=tb&rsv_enter=1&oq=%25E8%2580%2581%25E5%2585%25AD&rsv_btype=t&inputT=979&rsv_t=21bcxrY0AZ1A%2F6J%2Fwt9Df3GS275Vte3aFI2BHLB9oWsX7K5JXPS08ZVYR0aKZ97NVsfq&rsv_pq=fcb208890000b954&rsv_sug3=17&rsv_sug1=15&rsv_sug7=100&rsv_sug2=0&rsv_sug4=979

https://www.baidu.com/s?wd=nba



   -->

   <script>

    const inp = document.querySelector('input');
    const ul = document.querySelector('ul');

    inp.oninput = function () {
        const val = this.value;
        // console.log(val)
        const script = document.createElement('script');
        script.src = `https://www.baidu.com/sugrec?pre=1&p=3&ie=utf-8&json=1&prod=pc&from=pc_web&sugsid=37379,36546,37355,36885,34813,36569,37173,37260,26350,37344,37372,37223&wd=${ val }&req=2&csor=1&cb=fn&_=1663138861265`;
        document.body.appendChild(script);
    }


    function fn(res){
        ul.innerHTML = res.g.reduce((prev,item)=>{
          return  prev + `<li>${item.q}</li>`
        },'')

        ul.style.display = 'block'

    }

   </script>
</body>
</html> 